package logic

import (
	"context"
	"taobao/models/mysql"

	"taobao/taobaorpc/internal/svc"
	"taobao/taobaorpc/taobaorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShopPerfectLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShopPerfectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShopPerfectLogic {
	return &ShopPerfectLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ShopPerfectLogic) ShopPerfect(in *taobaorpc.ShopPerfectRequest) (*taobaorpc.ShopPerfectResponse, error) {
	// todo: add your logic here and delete this line
	shop := mysql.Shop{
		HeadImage: in.HeadIamge,
		Name:      in.Name,
		Price:     float64(in.Price),
		UserId:    in.UserId,
	}
	mysql.DB.Debug().Create(&shop)
	return &taobaorpc.ShopPerfectResponse{
		ShopId: int64(shop.ID),
	}, nil
}
